package com.yelink.metrics.api.dto;

import com.yelink.metrics.core.constant.enums.FieldDefine;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;

import java.util.Objects;

/**
 * 表结构定义 插入/更新
 * @author idea
 */
@Data
@Builder
@ToString
@AllArgsConstructor
@NoArgsConstructor
public class TableColumnDTO {

    /**
     * 数据库
     */
    private String tableSchema;

    /**
     * 表名
     */
    private String tableName;

    /**
     * 表注释
     */
    private String tableRemark;

    /**
     * 字段编码
     */
    private String fieldCode;

    /**
     * 字段中文名
     */
    private String fieldName;

    /**
     * 字段类型
     */
    private String fieldType;

    /**
     * 字段长度
     */
    private Integer fieldLength;

    /**
     * 小数点
     */
    private Integer fieldPoint;

    private String fieldRemark;

    private FieldDefine fieldDefine;

    public String buildUniCode() {
        return this.tableSchema + ": " + this.tableName + ": " + this.fieldCode;
    }


    public boolean equalsIgnoreSome(TableColumnDTO other) {
        if (other == null) {
            return false;
        }
        return Objects.equals(this.tableSchema, other.tableSchema)
                && Objects.equals(this.tableName, other.tableName)
                && Objects.equals(this.tableRemark, other.tableRemark)
                && Objects.equals(this.fieldCode, other.fieldCode)
                && Objects.equals(this.fieldName, other.fieldName)
                && Objects.equals(this.fieldType, other.fieldType)
                && Objects.equals(this.fieldRemark, other.fieldRemark)
                && Objects.equals(this.fieldDefine, other.fieldDefine);
    }
}
